package com.cadre.system.service.impl;

import com.cadre.system.domain.officer.DIC_ZB;
import com.cadre.system.domain.officer.Tree;
import com.cadre.system.domain.officer.DIC_View;
import com.cadre.system.service.DIC_ZBService;
import com.cadre.system.mapper.DIC_ZBMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service("dIC_ZBService")
public class DIC_ZBServiceImpl implements DIC_ZBService {
    @Autowired
    private DIC_ZBMapper DIC_ZBMapper;

    @Override
    public List<DIC_ZB> getAll(Map<String, Object> map) {
        return this.DIC_ZBMapper.selectAll(map);
    }

    @Override
    public List<Tree> getAllForTree(Map<String, Object> map) {
        return this.DIC_ZBMapper.getAllForTree(map);
    }

    @Override
    public List<DIC_ZB> selectAllLikeName(Map<String, Object> map) {
        return this.DIC_ZBMapper.selectAllLikeName(map);
    }

    @Override
    public int createTable(Map<String, Object> map) {
        return this.DIC_ZBMapper.createTable(map);
    }

    @Override
    public int dropTable(Map<String, Object> map) {
        return this.DIC_ZBMapper.dropTable(map);
    }

    @Override
    public List<DIC_View> selectViewDic() {
        return this.DIC_ZBMapper.selectViewDic();
    }

    @Override
    public int comment(Map<String, Object> map) {
        return this.DIC_ZBMapper.comment(map);
    }

    @Override
    @Transactional(rollbackFor = {Exception.class})
    public int insertSelective(Map<String, Object> map) {
        return this.DIC_ZBMapper.insertSelective(map);
    }

    @Override
    @Transactional(rollbackFor = {Exception.class})
    public int updateByPrimaryKeySelective(Map<String, Object> map) {
        return this.DIC_ZBMapper.updateByPrimaryKeySelective(map);
    }

    @Override
    @Transactional(rollbackFor = {Exception.class})
    public int deleteByPrimaryKey(Map<String, Object> map) {
        return this.DIC_ZBMapper.deleteByPrimaryKey(map);
    }

    @Override
    public List<DIC_ZB> selectAllByImportance(Map<String, Object> map) {
        return this.DIC_ZBMapper.selectAllByImportance(map);
    }

    @Override
    public List<DIC_ZB> selectChildNodes(Map<String, Object> map) {
        return this.DIC_ZBMapper.selectChildNodes(map);
    }

    @Override // com.tdqy.cadre.modular.profess.service.DIC_ZBService
    public DIC_ZB selectByTableNameAndCode(String tableName, String code) {
        DIC_ZB dicZb;
        if (!StringUtils.isNotBlank(tableName) || !StringUtils.isNotBlank(code) || null == (dicZb = this.DIC_ZBMapper.selectByTableNameAndCode(tableName, code))) {
            return null;
        }
        return dicZb;
    }

    @Override // com.tdqy.cadre.modular.profess.service.DIC_ZBService
    public List<DIC_ZB> selectChengjieMingcheng(String rootId) {
        List<DIC_ZB> dic_zbs;
        new ArrayList();
        if (rootId.equals("00")) {
            dic_zbs = this.DIC_ZBMapper.selectChengjieMingchengIsnull();
        } else {
            dic_zbs = this.DIC_ZBMapper.selectChengjieMingcheng(rootId);
            for (DIC_ZB dicZb : dic_zbs) {
                dicZb.setCode(dicZb.getCode() + "@" + dicZb.getImportance());
            }
        }
        return dic_zbs;
    }
}
